package com.example.yucheng.util;

import com.example.yucheng.util.ResultMsgEnum;

public class Result<T> {
    private int code;
    private String message;
    private T data;

    public Result() {
    }

    public Result(int code, String message){
        this.code=code;
        this.message=message;
    }

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<T>();

        result.setCode(ResultMsgEnum.SUCCESS.getCode());

        result.setMessage(ResultMsgEnum.SUCCESS.getMessage());

        result.setData(data);

        return result;

    }
    public static <T> Result<T> error(int code, String message) {

        return new Result(code, message);

    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage(){
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
